package com.zy.garbage.controller;

import io.jsonwebtoken.Claims;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BaseController {
    public HttpServletRequest request;
    public HttpServletResponse response;
    public Claims claims;
    public String token;

    @ModelAttribute
    public void serResAndReq(HttpServletRequest request,HttpServletResponse response) {
//        把token和登录信息存进session
        this.request = request;
        this.response = response;
        Object object = request.getAttribute("user_claims");
        Object object1 = request.getAttribute("user_token");
        if (object != null) {
            this.claims = (Claims) object;
            this.token = (String) object1;
        }
    }
}
